home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / boosters.arc / MOVEBLK.ASM < prev    next >
Encoding:
Assembly Source File  |  1985-10-13  |  2.8 KB  |  167 lines

  1. ;*****************************************************
  2. ;
  3. ;       Procedure MOVEBLK(X1,Y1,X2,Y2,X3,Y3: Integer);
  4. ;                 offset  14,12,10,08,06,04  from BP
  5. ;
  6. ;       Moves block from screen at X1,Y1,X2,Y2
  7. ;                               to X3,Y3
  8. ;*****************************************************
  9. MoveBlk proc    near
  10.         push    bp
  11.     mov    bp,sp
  12.     push    ds
  13. ;
  14. ;
  15. ;*** Compute number of lines to move
  16. ;
  17.     mov    ax,[bp+12]    ; Y1
  18.     mov    cx,[bp+08]    ; Y2
  19.         sub     cx,ax           ; CX = Y2 - Y1
  20.     inc    cx        ; Number of lines
  21. ;
  22. ;
  23. ;*** Compute length of each move
  24. ;
  25.     mov    ax,[bp+14]    ;  X1
  26.     mov    dx,[bp+10]    ;  X2
  27.     sub    dx,ax        ;  DX = X2 - X1
  28.     inc    dx        ;  num WORDS/line
  29.     shl    dx,1        ;  num bytes/line
  30.     mov    bx,cx
  31. ;
  32. ;*** Compute workspace needed on stack
  33. ;
  34. wksp:    sub    sp,dx
  35.     loop    wksp
  36. ;
  37.     mov    ax,ss
  38.     mov    es,ax
  39.     mov    di,sp        ;  ES:DI has stack address
  40.     push    dx
  41.     push    bx
  42.  
  43. ;
  44. ;*** Determine Video Address
  45. ;
  46.     mov    bx,449h
  47.     xor    ax,ax
  48.     mov    ds,ax
  49.     mov    al, [bx]
  50.     cmp    al,7
  51.     jne    graphx
  52.     mov    dx,0B000h
  53.     jmp    m001
  54. graphx:
  55.     mov    dx,03DAh    ; for IBM CGA,
  56. VR:    in    al,dx        ; we must do this
  57.     and    al,1000b    ; so we won't see
  58.     jz    vr        ; snow
  59.     mov    dx,0B800h
  60. m001:    mov    ds,dx
  61. ;
  62. ;*** Compute source address for move to stack
  63. ;
  64.     mov    si,[bp+12]    ;  Y1
  65.         dec     si              ;  (Y1-1)
  66.     mov    dx,si        ;  Save in DX
  67.     mov    cl,7
  68.     shl    dx,cl        ;  (Y1-1) * 128
  69.     mov    cl,5
  70.     shl    si,cl        ;  (Y1-1) *  32
  71.     add    si,dx        ;  (Y1-1) * 160
  72.     mov    ax,[bp+14]    ;  X1
  73.     dec    ax        ;  (X1-1)
  74.     shl    ax,1        ;  2 * (X1-1)
  75.     add    si,ax        ;  SI = up left off
  76. ;
  77.     pop    dx        ; Number of lines
  78.     pop    cx        ; Bytes/line
  79.     shr    cx,1        ; Words/line
  80.     push    ds
  81.     push    si
  82. ;
  83.     push    dx
  84.     push    cx
  85. ;
  86. ;*** Move block from screen to stack
  87. ;
  88.     mov    ax,160
  89.     sub    ax,cx
  90.     sub    ax,cx
  91.     cld
  92. MOVE1:  push    cx
  93. rep    movsw
  94. ;
  95.     pop    cx
  96.     dec    dx
  97.     jz    DONE1
  98.     add    si,ax
  99.     jmp    MOVE1
  100. ;
  101. ;*** Blank object on screen
  102. ;
  103. DONE1:  pop     cx
  104.     pop    dx
  105.     pop    di
  106.     pop    es
  107.     push    dx
  108.     push    cx
  109.     mov    bx,160
  110.     sub    bx,cx
  111.     sub    bx,cx
  112.         mov     ax,0E20h
  113.     cld
  114. AGAIN:    push    cx
  115. rep    stosw
  116. ;
  117.     pop    cx
  118.     dec    dx
  119.     jz    DONE2
  120.     add    di,bx
  121.     jmp    AGAIN
  122. ;
  123. ;*** Move saved object from stack workspace
  124. ;*** to new location on screen
  125. ;
  126. DONE2:    mov    di,[bp+04]    ;  Y3
  127.         dec     di              ;  (Y3-1)
  128.     mov    dx,di        ;  Save in DX
  129.     mov    cl,7
  130.     shl    dx,cl        ;  (Y3-1) * 128
  131.     mov    cl,5
  132.     shl    di,cl        ;  (Y3-1) *  32
  133.     add    di,dx        ;  (Y3-1) * 160
  134.     mov    ax,[bp+06]    ;  X3 into AX
  135.     dec    ax        ;  (X3-1)
  136.     shl    ax,1        ;  2 * (X3-1)
  137.     add    di,ax        ;  DI=up left of new loc
  138. ;
  139. ;*** Move block
  140. ;
  141.     pop    cx
  142.     pop    dx
  143.         mov     si,sp
  144.     mov    ax,ss
  145.     mov    ds,ax
  146. ;
  147.     mov    ax,160
  148.     sub    ax,cx
  149.     sub    ax,cx
  150.     cld
  151. MOVER:  push    cx
  152. rep    movsw
  153. ;
  154.     pop    cx
  155.     dec    dx
  156.     jz    DONE3
  157.     add    di,ax
  158.         jmp     MOVER
  159. ;
  160. DONE3:    mov    sp,bp
  161.     sub    sp,2
  162.         pop     ds
  163.         mov     sp,bp
  164.         pop     bp
  165.     ret    12
  166. MoveBlk endp
  167.